package com.aiit.dao;

import com.aiit.pojo.NameValue;
import com.aiit.pojo.order.SaleOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ISaleOrderDao extends BaseMapper<SaleOrder> {
    @Select("select id from t_sale_order where deleted=1 and state=1")
    List<SaleOrder> querySaleId();
    @Select("select  * from t_sale_order where deleted=1 and state=1 and id=#{id}")
    SaleOrder selectById2(int id);
    @Select("select * from t_sale_order where deleted=1 and state=1 and lingjian_id=#{lingjianId} and customer_id=#{customerId}")
    List<SaleOrder> queryByLCId(@Param("lingjianId") Integer lingjianId,@Param("customerId") Integer customerId);
    @Select("select * from t_sale_order where deleted=1 and lingjian_id=#{lingjianId} and user_id=#{userId}")
    List<SaleOrder> queryByLUId(@Param("lingjianId") Integer lingjianId,@Param("userId") Integer userId);
    @Select("select * from t_sale_order where deleted=1 and state=1 and lingjian_id=#{lingjianId}")
    List<SaleOrder> queryByLId(Integer lingjianId);
    @Select("select * from t_sale_order where deleted=1 and lingjian_id=#{lingjianId}")
    List<SaleOrder> queryByLId2(Integer lingjianId);
    @Select("select * from t_sale_order where deleted=1 and state=1 and customer_id=#{customerId}")
    List<SaleOrder> queryByCId(Integer customerId);
    @Select("select * from t_sale_order where deleted=1 and user_id=#{userId}")
    List<SaleOrder> queryByUId(Integer userId);
    @Select("select * from t_sale_order where deleted=1 and state=1")
    List<SaleOrder> queryAll1();
    @Select("select * from t_sale_order where deleted=1 and state=2")
    List<SaleOrder> queryAll2();
    @Select("select l.name ,SUM(s.number) VALUE from t_lingjian l,t_sale_order s WHERE s.state=1 and s.deleted=1 and l.deleted=1 and s.lingjian_id=l.id group by lingjian_id")
    List<NameValue> queryAllSum();
}
